#pragma once
#include "Mario.h"
#include "Sprites.h"

#define	BULLET_SPEED  0.8

class CBullet :public CEnemy
{
private:
	LPDIRECT3DTEXTURE9	_imageBullet;
public:	
	static int countBullet;
	CBullet(void);
	CBullet(QuadTree* q,Direction dir,int left,int top,CScreen *scr);
	//static void InitResoure(){}
	void Draw(int VirtualLeft,int Style);
	int Move();
	void Collision(Object *Ob);
	void Release()
	{
		if(countBullet>0)
			countBullet--;
	}
	~CBullet(void);
};


class BulletManager
{
	int	MaxBullet;//max bullet
	DWORD OldTime;
	DWORD deltaTimeBullet;//time delay

public:


	BulletManager(int maxB,DWORD delta)
	{	OldTime=GetTickCount();
	MaxBullet=maxB;
	deltaTimeBullet=delta;
	}
	bool AddBullet(QuadTree* q,Direction dir,int left,int top,CScreen *scr)
	{
		if(GetTickCount()-OldTime<deltaTimeBullet||CBullet::countBullet>MaxBullet)
			return false;
		OldTime=GetTickCount();
		Object *Ob=new CBullet(q,dir,left,top,scr);
		q->Add(q->_pRoot,Ob);
		CBullet::countBullet++;
		return true;
	}
	void Reset()
	{
		OldTime=GetTickCount();
		CBullet::countBullet=0;
	}
};